import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:pmviewer/message.dart';
import 'app/routes/app_pages.dart';
import 'package:display_metrics/display_metrics.dart';

void main() async {
  await GetStorage.init();
  runApp(const PMApp());
}

class PMApp extends StatelessWidget {
  const PMApp({super.key});

  @override
  Widget build(BuildContext context) {
    return OrientationBuilder(builder: (context, orientation) {
      var locale = const Locale('en', 'US');
      return ScreenUtilInit(
          designSize: const Size(360, 760), // 设计尺寸
          minTextAdapt: true,
          splitScreenMode: true,
          builder: (_, child) {
            return DisplayMetricsWidget(
              child: GetMaterialApp(
                debugShowCheckedModeBanner: false,
                title: 'Patient Monitor Viewer',
                initialRoute: AppPages.INITIAL,
                getPages: AppPages.routes,
                theme: ThemeData(
                  colorScheme:
                      ColorScheme.fromSeed(seedColor: Colors.deepPurple),
                  useMaterial3: true,
                ),
                translations: Messages(),
                locale: locale,
                // locale: const Locale('zh', 'CN'),
                fallbackLocale: const Locale('en', 'UK'),
              ),
            );
          });
    });
  }
}
